#!/usr/bin/env python

import pkg_resources
pkg_resources.require("TurboGears")
import asyncore
import cherrypy
import turbogears

from cherrypy._cpwsgi import wsgiApp
from scgi_server import SCGIServer

from os.path import *
import sys

turbogears.update_config(configfile="prodcfg.py",
                         modulename="fasttrack.config")

port = 4000
if len(sys.argv) > 1:
    port = int(sys.argv[1])

from fasttrack.controllers import Root

cherrypy.root = Root()
cherrypy.server.start(initOnly=True, serverClass=None) 
server = SCGIServer(wsgiApp, '', host='localhost', port=4000)
asyncore.loop()